package com.example.cloud.lijianeurekaclient;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.TimeUnit;

@Configuration
@ComponentScan
@EnableAutoConfiguration
@EnableEurekaClient
@RestController
public class LijianEurekaServerApplication {

    private final Logger logger = Logger.getLogger(getClass());

    @RequestMapping("/")
    public String home() {
        return "Hello world ,this is test eureka client ";
    }

    @Value("${server.port}")
    String port;

    @RequestMapping("/showport")
    public String showport() {
        logger.info("this is lijian-eureka-client " + port);
        return "from port:" + port;
    }

    @RequestMapping("/hi")
    public String hi() {
        try {
            logger.error("try to sleep");
            TimeUnit.MINUTES.sleep(2);
        } catch (Exception e) {
            logger.error(e.getMessage());
        }
        logger.info("this is lijian-eureka-client hi ");
//        int i=1/0;
        return "this is lijian-eureka-client hi";
    }


    public static void main(String[] args) {
        SpringApplication.run(LijianEurekaServerApplication.class, args);
    }
}
